<template>
  <div>
    <div class="add" @click="add">新增</div>
    <page-list
      :url="url"
      :params="filter"
      :needSearch="false"
      @initList="_initList"
      ref="pageList"
    >
      <van-cell
        class="card"
        @click="openDetail(item)"
        v-for="(item, index) in list"
        :key="index"
      >
        <div>
          <div>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_company_check.png"
                />作业类型：{{ item.DangerOperateTypeName }}
              </van-col>
            </van-row>
           <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_danger_main_assign.png"
                />上报日期: {{ item.ApplyDate.substring(0,10) }}
              </van-col>
            </van-row>

            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_danger_main_assign.png"
                />开始时间: {{ item.StartDate.substring(0,10) }}
              </van-col>
            </van-row>
           <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_danger_main_assign.png"
                />结束时间: {{ item.EndDate.substring(0,10) }}
              </van-col>
            </van-row>

            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_equ_type.png"
                />作业方: {{ item.OperateObjName }}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_equ_supplier.png"
                />监护人员: {{ item.WatchMan }}
              </van-col>
            </van-row>
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_area.png"
                />位置: {{ item.Location }}
              </van-col>
            </van-row>
            
            
            
            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_list_customer.png"
                />录入人: {{ item.CreateChnName }}
              </van-col>
            </van-row>

            <van-row gutter="20">
              <van-col>
                <img
                  class="icon"
                  src="@/assets/Images/AppIcon/icon_danger_main_assign.png"
                />录入时间: {{ item.CreateDate.substring(0,10) }}
              </van-col>
            </van-row>

            <FileUpload
              @CallBack="_fileUploadCb"
              :attachs=" item.Attachs"
              :labelName="'施工作业记录'"
              :allowEdit="false"
            />
            <van-row>
              <van-col span="24">
                <div class="dep_btm">
                  <div
                    class="btm_item"
                    @click.stop="deleteData(item)"
                    v-if="item.Status != 100"
                  >
                   <img src="@/assets/Images/AppIcon/icon_list_delete_red.png" alt="" />
                    <div class="mr-10">删除</div>
                  </div>
                  <div
                    class="btm_item"
                    @click.stop="openBian(item)"
                    style="margin-right: 15px"
                    v-if="item.Status != 100"
                  >
                    <img src="@/assets/Images/AppIcon/icon_list_use.png" alt="" />
                    <div>编辑</div>
                  </div>
                  <div
                    class="btm_item"
                    @click.stop="openEdit(item)"
                    style="margin-right: 15px"
                    v-if="item.Status != 100"
                  >
                   <img src="@/assets/Images/AppIcon/icon_list_edit.png" alt="" />
                    <div>施工结束</div>
                  </div>
                  <div
                    class="btm_item"
                    @click.stop="openDetail(item)"
                    style="margin-right: 15px"
                  >
                    <img src="@/assets/Images/AppIcon/icon_list_view.png" alt="" />
                    <div>详情</div>
                  </div>
                </div>
              </van-col>
            </van-row>
          </div>
        </div>
      </van-cell>
    </page-list>
  </div>
</template>

<script>
import PageList from "../SiteDangerOperateApplyRecord/PageList.vue";
import { getMenuByMenuCode } from "@/api/common";
import FileListReadOnly from "../../../components/Attach/FileListReadOnlyYat.vue";
export default {
  components: { PageList,FileListReadOnly },
  data() {
    return {
      rightValue: 0,
      // GET /api/SiteDangerOperateApplyRecordNew/GetPageData
      url: '/SiteDangerOperateApplyRecordNew/GetPageData',
      list: [],
      filter: {
      },
    };
  },
  created() {
    this.getMenuByMenuCode();
  },
  methods: {
    _initList(list) {
      this.list = list;
    },
    openDetail(item) {
      this.$router.push({
        path: "/SiteDangerOperateApplyRecord/Detail",
        query: { id: item.ID, templateId: item.TemplateId },
      });
    },

    _fileUploadCb(attachs) {
			this.data.Attachs = attachs;
		},
    
    add() {
      this.$router.push({ path: "/SiteDangerOperateApplyRecord/Edit" ,
        query: { id: 0 },});
    },

    openEdit(obj) {
      this.$router.push({
        path: "/SiteDangerOperateApplyRecord/jieshu",
        query: { id: obj.ID , templateId: obj.TemplateId },
      });
      return true;
    },
    openBian(obj){
        this.$router.push({
        path: "/SiteDangerOperateApplyRecord/Edit",
        query: { id: obj.ID , templateId: obj.TemplateId },
      });
      return true;
    },
    // GET /api/SiteDangerOperateApplyRecordNew/Delete/{id}
    deleteData(item) {
      this.$dialog
        .confirm({
          title: "询问",
          message: "您确定要删除该上报记录吗？",
        })
        .then(() => {
          let params = { id: item.ID };
          this.$axios
            .get('/SiteDangerOperateApplyRecordNew/Delete/{id}', {
              params: params,
            })
            .then((res) => {
              this.$toast("删除成功");
              this.$refs.pageList.refreshList();
            });
        })
    },
    getMenuByMenuCode() {
      var me = this;
      getMenuByMenuCode("GxInterviewRecord_List").then((res) => {
        me.rightValue = res.data ? res.data.RoleRightValue : 0;
      });
    },
  },
};
</script>
<style lang="less" scoped>
.dep_btm {
  display: flex;
  justify-content: flex-end;
  line-height: 27px;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}

.icon {
  vertical-align:middle;
}
</style>
